<?php
include('conf.php');
//CURL_HTTP_VERSION_1_0
function checkstr($str,$needle){
    $tmparray = explode($needle,$str);
    if(count($tmparray)>1){
    return true;
    } else{
    return false;
    }
}
if(isset($_GET['getloc'])){
    $u = $_GET['getloc'];
	$obj = new RedirectUrl($u); 
    $v = $obj->get_final_url(); 
    if(1==1){
		echo json_encode(array(error_code=>0,u=>$v));
    }else{
        //echo file_get_contents($u);
    }
}elseif(isset($_GET['getcode'])){
    $ux="https://openapi.baidu.com/oauth/2.0/token";
    $ud=array(
    	"grant_type"=>"device_token",
		"code"=>$_GET['code'],
		"client_id"=>AK,
		"client_secret"=>SK,
    );
    echo Hpost($ux,$ud);
}else{
    $ux="https://openapi.baidu.com/oauth/2.0/device/code";
    $ud=array(
    	"response_type"=>"device_code",
		"client_id"=>AK,
		"scope"=>"basic,netdisk"
    );
    echo Hpost($ux,$ud);
}